package com.songminju.jsong_beanwithsql.datasource;

import java.beans.PropertyVetoException;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.songminju.jdagger.util.ConfigReader;

/**
@todo
@description
@author songminju
@date 2017年12月3日
*/
public class DataSourceFactory {
	private static String filePath = "jdbc.properties";
	public static ComboPooledDataSource c3p0DateSource() {
		ConfigReader cr = new ConfigReader(filePath);
		ComboPooledDataSource cpds = new ComboPooledDataSource();
		try {
			cpds.setDriverClass(cr.get("driver"));
		} catch (PropertyVetoException e) {
			e.printStackTrace();
		}
		cpds.setJdbcUrl(cr.get("url"));
		cpds.setUser(cr.get("username"));
		cpds.setPassword(cr.get("password"));
		cpds.setMinPoolSize(3);
		cpds.setAcquireIncrement(3);
		cpds.setMaxPoolSize(20);
		cpds.setMaxStatementsPerConnection(100);
		return cpds;
	}
}
